package com.lineage.server.datatables.lock;

import com.lineage.server.datatables.sql.CharOtherTable2;
import com.lineage.server.datatables.storage.CharOtherStorage2;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.templates.L1PcOther2;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class CharOtherReading2 {
  private final Lock _lock = new ReentrantLock(true);
  
  private final CharOtherStorage2 _storage = (CharOtherStorage2)new CharOtherTable2();
  
  private static CharOtherReading2 _instance;
  
  public static CharOtherReading2 get() {
    if (_instance == null)
      _instance = new CharOtherReading2(); 
    return _instance;
  }
  
  public void load() {
    this._lock.lock();
    try {
      this._storage.load();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public L1PcOther2 getOther(L1PcInstance pc) {
    L1PcOther2 tmp;
    this._lock.lock();
    try {
      tmp = this._storage.getOther(pc);
    } finally {
      this._lock.unlock();
    } 
    return tmp;
  }
  
  public void storeOther(int objId, L1PcOther2 other) {
    this._lock.lock();
    try {
      this._storage.storeOther(objId, other);
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void tam() {
    this._lock.lock();
    try {
      this._storage.tam();
    } finally {
      this._lock.unlock();
    } 
  }
}
